﻿using System.Collections.Generic;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MyCompany.WebCrawler.Repositories;

namespace MyCompany.WebCrawler.Test.RepositoryTest.Given_Database
{
    [TestClass]
    public class When_SaveTwoLinks : Context
    {
        private Repository repository;
        private string url1 = "http://google.com";
        private string url2 = "http://bing.com";
        private string url3 = "http://gmail.com";
        private List<Url> links;

        public override void Arrange()
        {
            repository = new Repository();
            repository.Clean();
        }

        public override void Act()
        {
            repository.Save(url1);
            links = repository.Load();
            repository.Save(url2);
            repository.Save(url3);
            links = repository.Load();
        }

        [TestMethod]
        public void Then_2ulrsWereLoaded()
        {
            links.Count.Should().Be(2);
        }

        [TestMethod]
        public void Then_TheFirstOne()
        {
            links[0].Path.Should().Be(url2);
        }
        
        [TestMethod]
        public void Then_TheSecondOne()
        {
            links[1].Path.Should().Be(url3);
        }
    }
}